﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEngine.SceneManagement;

namespace Nirvana
{
    /// <summary>
    /// 同步场景ab加载携程
    /// </summary>
    public sealed class WaitLoadSceneProgress : WaitLoadAssetProgress
    {
#if UNITY_EDITOR
        public WaitLoadSceneProgress(string bundle,string assetname,LoadSceneMode loadSceneMode)
        {
            string[] assetnames = AssetDatabase.GetAssetPathsFromAssetBundleAndAssetName(bundle, System.IO.Path.GetFileNameWithoutExtension(assetname));
            if(assetnames.Length == 0)
            {
                base.Error = string.Format("There is no scene with name \"{0}\" in \"{1}\"", bundle, assetname);
                return;
            }

            if(loadSceneMode == LoadSceneMode.Additive)
            {
               EditorApplication.LoadLevelAdditiveInPlayMode(assetnames[0]);
            }
            else
            {
               EditorApplication.LoadLevelInPlayMode(assetnames[0]);
            }
        }
#endif

        public override float Progress
        {
            get
            {
                return 1;
            }
        }
        /// <summary>
        /// 等待携程中断返回
        /// </summary>
        public override bool keepWaiting
        {
            get
            {
                return false;
            }
        }

        public override bool Load()
        {
            return false;
        }

    }
}

